import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

public class Naming {

	private static Map<Integer, String> jinMap = new HashMap<Integer, String>() {
		{
			put(4, new String("心 仁 少 升"));
			put(5, new String("正 生 石"));
			put(6, new String("如 字"));
			put(7, new String("作 成"));
			put(10, new String("刚 书 师 宸 真 峻 笑"));
			put(11, new String("常 欣 祥 悦 晨"));
			put(12, new String("顺 众 超 朝 宁 舒 善 词 盛 钧 胜 斯"));
			put(13, new String("愉 裕 新 愈 载 诗"));
			put(14, new String("铭 诚 慈 慎 瑜 睿 瑞"));
			put(15, new String("锐 冲 稹 绪 挚 实 节 数 剑"));
			put(17, new String("锴"));
			put(18, new String("镇 镕"));
			put(20, new String("钟"));
			put(21, new String(""));
			put(22, new String("铸 鉴"));
			put(24, new String("鑫"));
		}
	};
	private static Map<Integer, String> muMap = new HashMap<Integer, String>() {
		{
			put(4, new String("木 元 月 今 公 介 匀 亢"));
			put(5, new String("可 加 玉 巧 本 功 外 未 甘 古"));
			put(6, new String("聿 匡 旭 竹 共 企 曲 朵 吉"));
			put(7, new String("见 君 材 克 言"));
			put(10, new String("原 桐 珂 恪 隽 起 柏 高 格 拱 桓 珈 家 "));
			put(11, new String("启"));
			put(12, new String("凯 尧 第 栋 棋 乔 祁 茗 杰 植 笔 几 集 荃 森"));
			put(13, new String("经 勤 业 义 琪 琳 琦"));
			put(14, new String("荣 纲 赫 槐 嘉 菘 萄 语 愿"));
			put(15, new String("瑰 庆 赓 葆 巩 广 稷 翦 葵 箴 贤 仪 毅 "));
			put(17, new String("阶 岳"));		
			put(18, new String("柠 简 谨 "));		
			put(20, new String("严 觉 继 "));
			put(21, new String("艺 蕴 颢"));
			put(22, new String("苏 权 蘅 "));
			put(23, new String(""));
			put(24, new String(""));
		}
	};
	private static Map<Integer, String> shuiMap = new HashMap<Integer, String>() {
		{
			put(4, new String("文"));
			put(5, new String("民 平 禾 弘"));
			put(6, new String("合 名 "));
			put(7, new String("甫 宏 江 孝"));
			put(10, new String("航 洵 珀 洋 恒 洪 训"));
			put(11, new String("雪 海 望 习 敏 斌"));
			put(12, new String("云 淇 清"));
			put(13, new String("晖"));
			put(14, new String("鸣 华 源"));
			put(15, new String("辉 霄 震 霆 墨"));
			put(17, new String("鸿 泽 璞"));
			put(18, new String("涛 穗"));
			put(20, new String("怀"));
			put(21, new String("邈"));
			put(22, new String("欢 "));
			put(24, new String(""));
			put(24, new String(""));
		}
	};
	private static Map<Integer, String> tuMap = new HashMap<Integer, String>() {
		{
			put(2, new String("又"));
			put(4, new String("予 友"));
			put(5, new String("永 用 由 以 "));
			put(6, new String("宇 安 "));
			put(7, new String("辰 延"));
			put(10, new String("容 轩 益 "));
			put(11, new String("迎 庸 伟 培 为 唯"));
			put(12, new String("为 砚 翔"));
			put(13, new String("爱 意"));
			put(14, new String("维 玮"));
			put(15, new String("卫 逸 磊 增 纬"));
			put(17, new String("阳 远"));
			put(18, new String("韫"));			
			put(20, new String(""));
			put(21, new String("巍 跃 誉"));
			put(22, new String(""));
			put(23, new String("岩"));
			put(24, new String(""));
		}
	};
//	private static Set<Integer> goodNumber = new HashSet<Integer>() {
//		{
//			add(5);
//			add(6);
//			add(7);
//			add(8);
//			add(13);
//			add(15);
//			add(16);
//			add(21);
//			add(23);
//			add(29);
//			add(31);
//			add(32);
//			add(33);
//			add(35);
//			add(37);
//		}
//	};
	
	private static Set<Integer> goodNumber = new HashSet<Integer>() {
		{
			add(1);
			add(3);
			add(5); 
			add(7);
			add(8);
			add(11);
			add(13);
			add(15);
			add(16);
			add(18);
			add(21);
			add(23);
			add(24);
			add(25); 
			add(31);
			add(32);
			add(33);
			add(35);
			add(37);
			add(39);
			add(41);
			add(45);
			add(47);
			add(48);
			add(52);
			add(57);
		}
	};
	private static Set<String> additionalGoodNumber = new HashSet<String>() {
		{
			add("13-14");
			
		}
	};
	static int lastNameNumber = 11;
	static String lastName = "张";
	static Set<Integer> availableNumber = new TreeSet<Integer>();

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String outputFile="e:/names.txt";
		List<Map<Integer, String>> wuxingList = new ArrayList<Map<Integer, String>>();
		wuxingList.add(jinMap);
		wuxingList.add(muMap);
		wuxingList.add(shuiMap);
		wuxingList.add(tuMap);
		List<Map<Integer, String>> mustHaveList = new ArrayList<Map<Integer, String>>();
		mustHaveList.add(jinMap);
		List<Map<Integer, String>> nonMustHaveList = new ArrayList<Map<Integer, String>>();
		nonMustHaveList.add(muMap);
		nonMustHaveList.add(shuiMap);
		nonMustHaveList.add(tuMap);
		int counter = 0;
		LogWriter logger = new LogWriter(outputFile);
		 
		for (int i = 1; i < 25; i++) {
			for (int j = 1; j < 25; j++) {
				if ((goodNumber.contains(lastNameNumber + i)
						&& goodNumber.contains(j + i)
						&& goodNumber.contains(j + 1)
						&& goodNumber.contains(lastNameNumber + j + j))||
						additionalGoodNumber.contains(i+"-"+j)||
						(goodNumber.contains(lastNameNumber + i)
								&& goodNumber.contains(j + i)
								&& goodNumber.contains(lastNameNumber + j + j))||
								(goodNumber.contains(lastNameNumber + i)
										&& goodNumber.contains(j + i)
										&& goodNumber.contains(j + 1))
								
				) {
					  logger.log(i+"-"+j);
					availableNumber.add(i);
					availableNumber.add(j);
					 System.out.println(i+"-"+j);
					 int nameCounter4onezuhe =0;
					for (Map<Integer, String> wuxingMap : wuxingList) {
						for (Map<Integer, String> musthaveMap : mustHaveList) {
							if (wuxingMap.get(i) == null
									|| "".equals(wuxingMap.get(i))
									|| musthaveMap.get(j) == null
									|| "".equals(musthaveMap.get(j))) {
								//logger.log("no name match");
							} else {
								String[] fisrt = wuxingMap.get(i).split(" ");
								String[] second = musthaveMap.get(j).split(" ");
								for (int m = 0; m < fisrt.length; m++) {
									for (int n = 0; n < second.length; n++) {
										counter++;
										nameCounter4onezuhe++;
											logger.log(counter+"   "+lastName + fisrt[m] + second[n]);
										 
//										System.out.println(counter+"   "+lastName + fisrt[m]
//												+ second[n]);
									}
								}

							}
							
						}
					}
					for (Map<Integer, String> wuxingMap : nonMustHaveList) {
						for (Map<Integer, String> musthaveMap : mustHaveList) {
							if (wuxingMap.get(j) == null
									|| "".equals(wuxingMap.get(j))
									|| musthaveMap.get(i) == null
									|| "".equals(musthaveMap.get(i))) {
								
								 
							} else {
								String[] second= wuxingMap.get(j).split(" ");
								String[] fisrt = musthaveMap.get(i).split(" ");
								for (int m = 0; m < fisrt.length; m++) {
									for (int n = 0; n < second.length; n++) {
										counter++;
										nameCounter4onezuhe++;
											logger.log(counter+"   "+lastName + fisrt[m] + second[n]);
										 
										
//										System.out.println(counter+"   "+lastName + fisrt[m]
//												+ second[n]);
									}
								}

							}
							
						}
					}
					if(nameCounter4onezuhe==0){
						logger.log("no name match");
					}

				}

			}
		}
		System.out.println("The available numbers are: ");
		for (Integer number : availableNumber) {
			 System.out.println(number);
		}
	}

}
